package com.liu.lab06.service.impl;



import com.liu.lab06.dao.MusicDao;
import com.liu.lab06.pojo.Music;
import com.liu.lab06.service.MusicService;

import java.util.List;

public class MusicServiceImpl implements MusicService {

    // 持有 DAO 引用，由 Spring 注入
    private MusicDao musicDao;

    public void setMusicDao(MusicDao musicDao) {
        this.musicDao = musicDao;
    }

    @Override
    public Music getMusicById(int id) {
        return musicDao.findMusicById(id);
    }

    @Override
    public List<Music> getAllMusics() {
        return musicDao.findAllMusics();
    }

    @Override
    public List<Music> searchMusicsByName(String key) {
        return musicDao.findMusicsByName(key);
    }

    @Override
    public List<Music> getMusicsByCategory(int categoryId) {
        return musicDao.findMusicsByCategory(categoryId);
    }

    @Override
    public int addMusic(Music music) {
        return musicDao.addMusic(music);
    }

    @Override
    public int updateMusic(Music music) {
        return musicDao.updateMusic(music);
    }

    @Override
    public int deleteMusic(int id) {
        return musicDao.deleteMusic(id);
    }
}
